package com.yeyaomai.dksns.flowis.dao;

import java.util.Date;
import java.util.LinkedHashMap;
import java.util.List;

import org.springframework.data.domain.Page;
import org.springframework.data.mongodb.core.mapreduce.GroupByResults;
import org.springframework.data.mongodb.core.mapreduce.MapReduceResults;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.data.mongodb.core.query.Update;

import com.yeyaomai.dksns.flowis.domain.Today;
import com.yeyaomai.dksns.flowis.domain.flowisdetail.FlowisQueryOrder;
import com.yeyaomai.dksns.flowis.domain.flowisdetail.FlowisStatDetailDTO;

/**
 * 
 * @author dingtao@yeyaomai.com
 */
public interface DetailDao  {
	
	/**
	 * pageNum  第几页
	 * pageSize 每页多少行
	 * orders   排序
	 * criterias 条件
	 * @return 
	 */
	public Page<FlowisStatDetailDTO>  getSplit(FlowisQueryOrder order) ;

	/**
	 * 返回总记录数
	 * @return  
	 */
	public  long getTotalSize(Query query,Class<FlowisStatDetailDTO> document);
	
	/**
	 * 
	 * @param dto
	 * @return
	 */
	public void insert(FlowisStatDetailDTO dto);
	
	
	/**
	 * 
	 * @return
	 */
	public void update(Criteria criteria, Update update);
	
	/**
	 * 
	 * @param conditionArgs
	 * @return
	 */
	public List<FlowisStatDetailDTO> getLastNumberByCondition(LinkedHashMap<String,String> conditionArgs);
	
	
	public <T> MapReduceResults<T> groupMapReduce(Query query, String map,String reduce, Class<T> clas);
	
	/**
	 * 分组统计
	 * @return 
	 */
	public <T> GroupByResults<T> group(Criteria criteria, String key, String map, String reduce, Class<T> clas);
	
	/**
	 * 分组统计 多参
	 * @return 
	 */
	public <T> GroupByResults<T> groups(Criteria criteria, String map, String reduce, Class<T> clas, String...key);
	/**
	 * 按条件查询
	 * @return
	 */
	public List<FlowisStatDetailDTO>  findList(Criteria criteria);
	
	public List<FlowisStatDetailDTO> findList(Query query);
	
	public FlowisStatDetailDTO findOne(Query query);
	
	/**
	 * 按条件删除集合
	 * @return
	 */
	public <T> void delete(Query query, Class<T> clas);
	
	public Today findFlowisStatDetailDTOByTime(Date date);
}
